Difference between revisions of "Python quick reference"

From thelinuxwiki
Jump to: navigation, search
(Simple statements)
Line 5: Line 5:
 
==Expressions==
 
==Expressions==
 
==Simple statements==
 
==Simple statements==
 +
===variable operations===
 +
'''assigenment examples'''
 +
 +
 +
>>> var1 = 'foo'
 +
>>> type(var1)
 +
<type 'str'>
 +
>>> print var1
 +
foo
 +
 +
 +
 +
 
===print===
 
===print===
  
Line 12: Line 25:
 
print multiple variables with text
 
print multiple variables with text
 
  print 'my variable are %s %s' % (FOO, BAR)
 
  print 'my variable are %s %s' % (FOO, BAR)
 +
 
==Common string operations==
 
==Common string operations==
  
 
print nth word of string
 
print nth word of string
 
  print s.split()[n]
 
  print s.split()[n]

Revision as of 15:21, 14 August 2017

Contents

Introduction

Lexical analysis

Data model

Execution model

Expressions

Simple statements

variable operations

assigenment examples


>>> var1 = 'foo'
>>> type(var1)
<type 'str'>
>>> print var1
foo



print

print sing variable named foo

print foo

print multiple variables with text

print 'my variable are %s %s' % (FOO, BAR)

Common string operations

print nth word of string

print s.split()[n]