python(三)
来源:互联网 发布:js 获取html属性值 编辑:程序博客网 时间:2024/06/07 01:44
花了两个半天把Python 简介 | 菜鸟教程的内容看完了。
现在是花时间练习代码的时候,只有多敲代码才可能变成老司机啊。
《Learn Python the Hard Way》
从本书开始刷代码:
Ex0: 学会使用powershell, windos的终端。新建一个目录,在目录中创建一个test.py.
python test.py
Ex6: f-string
.format()
type_of_people = 10x = f"There are {type_of_people} types of people"binary = "binary"do_not = "don't"y = f"Those who know {binary} and those who {do_not}"print(x)print(y)print(f"I said: {x}")print(f"I also said: '{y}'")a = Falsejoke_evaluation = "Isn't that joke so funny?!{}"print(joke_evaluation.format(a))w = "This is the left side of ..."e = "a string with a right side."print(w+e)
There are 10 types of peopleThose who know binary and those who don'tI said: There are 10 types of peopleI also said: 'Those who know binary and those who don't'Isn't that joke so funny?!FalseThis is the left side of ...a string with a right side.Ex8:
formatter = "{} {} {} {}"print(formatter.format(1, 2, 3, 4))print(formatter.format("one", "two", "three", "four"))print(formatter.format(True, False, False, True))print(formatter.format(formatter, formatter, formatter, formatter))print(formatter.format( "Try your", "Own text here", "Maybe a poem", "Or a song about fear"))
1 2 3 4one two three fourTrue False False True{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}Try your Own text here Maybe a poem Or a song about fear
Ex10:
‘’ 中要打“”则用\"
"“中要打''则用\'
\\打印\
\n 转行 \t制表符
''' '''之间可以直接打印' '' \ *等
Ex13:参数 解包 变量
将argv中的变量解包,依次赋予左边的变量名。really神奇的一种赋值方式
Ex14:提示和传递
则每次输入直接用>提示。使用argv模块时:
则必须使用终端的python test.py ss 这种方式传入参数。这是对文件传入参数的方式。可以进行简单的小游戏
Ex15:读取文件
python -m pydoc open 用pydoc查看python的文档,清晰明了
Ex18:
*args 与 脚本的传入参数argv非常像。就是一个[, ,...]
Ex25:
help(ex25)是ex25中的文档 即''' '''之间的文档
ex25的名称,其中的函数以及相应的说明
阅读全文
0 0
- Python三
- Python(三)
- python(三)
- python(三)
- Python 专题三 python 多线程
- Python基础(三) Python字符串
- Python之旅 三
- Python[三]:Coding Style
- Python学习(三)
- python三本书
- python学习笔记三
- python集锦(三)
- Python学习 代码 三
- python学习之三
- Python学习三
- Python入门(三)
- 学习Python (三)
- python challenge <三>
- javascript易错题
- ros使用usb硬件,调用固定设备名修改设备权限的设置方法
- Farmer John的故事
- Java连接数据库
- dell 成就 5470安装win10 ubuntu双系统方法
- python(三)
- 循环计算文本框值之间的差值
- Opencv-python接口:轮廓检测
- 记一次SQL查询
- 进程与线程-2、用户级线程切换过程
- uva 1404 求很大数的素数算法
- 网络流量监控告警
- AspectJ学习总结
- Dialog中存在radiogroup动态添加radiobutton的ID问题