python如果报错,bing/GitHub/ 某个网络推荐的网址 /百度
基本运算
数据:
加+ 减- 乘* 除/ 余数% 整除数// 几次方**
文字链:
合并文本 + :‘文本‘ + ’文本‘
复制文本 * : ‘string’ * 5
‘string’+‘string’可行
‘string’+ 数字 不可行
——若想让string和数字结合,需要将数字转换成string格式:
>>>str(29)
‘29’
>>>print(‘I am ‘ + str(29) + ‘ years old. ‘)
I am 29 years old.
例如
‘string’ * 数字 复制:
‘Alice’ * 5
‘Alice Alice Alice Alice Alice’
变量使用说明
1.variable 只能是一个单词
2.只能由字母,数字和下划线组成,其他符号均不可以
3.不能用数字作为variable的开始
4.有大小写区分,所以spam Spam spaM 是3个不同的变量
给你的变量一个描述性的内容使你的项目变得更易读。
开始+保存项目
本章学习的3种expression
Floating-point numbers
Strings
integers(整数)
遗留问题
1.下横线怎么输入
2.python中开始项目;保存python项目(我该怎么保存)+如何打开一个已保存的python项目;
3.为什么我输入的program和教材中教的不一样
4.据说python在终端上直接执行很麻烦,是否需要我ipython Notebook来搞 或者是建一个文件?或者下载编辑器?sourcetree是否就是编辑器?
5.我已经可以输入这个program 了,如何让他能够自动运行起来?
6.Why does this expression cause an error? How can you fix it?
'I have eaten ' + 99 + ' burritos.'
Extra credit: Search online for the Python documentation for the len() function. It will be on a web page titled “Built-in Functions.” Skim the list of other functions Python has, look up what the round() function does, and experiment with it in the interactive shell.
Print(‘I have eaten ‘ + ‘99’ + ‘burritos. ’)
The correct way is
'I have eaten ' + str(99) + ' burritos.'.
网友评论