//this is my first day to study python, in order to review, every day i will make notes (2016/7/31)
1. In python , there are many bulit-in funcation. you can user follow to find out hou many built-in funcation:
dir(__builtins__)
if you want get BIF detail, you can use follow code:
help(……) such as help(input),int()
2. In python, you should be care to indent, if not , it will appear a lots error.
such as follow ,because indent error ,it will appear an error:
temp = input(‘input a num you want:‘)
guess = int(temp)
if guess == 8:
print(‘you are right‘)
else:
print(‘you are wrong‘)
3. In python , when you define variable ,uppercase and lowercase is different.
such as:
temp = ‘roy‘
Temp = ‘wyg‘
temp and Temp is not same variable
4. In python , if you want to user ‘ in a string ,you can user escape charcters : \
such as:
print(‘Let\‘s go!‘)
5. In python , origin string is userful , maybe the follow result is not you except
such as :
str = ‘c:\now\data‘
print(str)
result is :
c:
ow\data
you can solve this proble by str = r‘c:\now\data‘ ,this code is equal to str = ‘c:\\now\\data‘
when you print(str), the result will be c:\now\data
6. In python , if a string , you want to change row ,you can user ‘‘‘ ,if you not user ‘‘‘ and change row ,it will appear an error
such as:
str = ‘‘‘this
is
me‘‘‘
print(str)
the result is :
this
is
me
7. import module , such as if you want a rand num , range is 1-10 and type is int ,how to achieve it
import random
randnum = random.randint(1,10)