Python
文章平均质量分 53
托马斯小火车喷雾又喷烟,一直喷,喷喷喷.
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
AWK 输出包含有root的行
输出包含有root的行awk -F ":" '/root/ {print $1, $3, $0}' passwordroot 0 root:x:0:0:root:/root:/bin/bashoperator 11 operator:x:11:0:operator:/root:/sbin/nologin原创 2020-11-12 10:23:47 · 33870 阅读 · 0 评论 -
Python 学习笔记 元组 xxxxxxx XXXXXXXXXX
Python 学习笔记 元组 xxxxxxx XXXXXXXXXXprint("=" * 20)dimensions = (200, 50)print(dimensions[0])print(dimensions[1])for demension in dimensions: print(demension)print("=" * 20)dimensions = (200, 50)print("Original dim...原创 2020-09-16 15:11:17 · 34012 阅读 · 0 评论 -
Python 学习笔记 列表 切片 xxxxxxx XXXXXXXXXX
Python 学习笔记 列表 切片 xxxxxxx XXXXXXXXXXprint("=" * 20)players = ['charles', 'martina', 'michael', 'florence', 'eli']print(players[0:3])print(players[1:4])print(players[:4])print(players[2:])print(players[-3:])for play...原创 2020-09-16 14:45:23 · 201840 阅读 · 1 评论 -
Python sum() TypeError: ‘int‘ object is not callable xxxxxxxxx XXXXXXXXXX
Python sum() TypeError: 'int' object is not callable xxxxxxxxx XXXXXXXXXX代码中定义了 sum 变量,导致sum()方法异常。原创 2020-09-16 13:52:40 · 32353 阅读 · 0 评论 -
Python 学习笔记 列表 range() xxx XXX
Python 学习笔记 列表 range() xxx XXXprint("-" * 30)for value in range(1, 5): print(value)numbers = list(range(1, 6))print(numbers)even_numbers = list(range(2, 11, 2))print(even_numbers)squares = []for value in r...原创 2020-09-16 13:46:51 · 31273 阅读 · 0 评论 -
Python 学习笔记 列表 for 循环 xxx XXX
Python 学习笔记 列表 for 循环 xxx XXXprint("-" * 30)magicians = ['alice', 'david', 'carolina']for magician in magicians: print(magician)for magician in magicians: print(magician.title() + ", that was a great trick!") print("I...原创 2020-09-15 10:50:14 · 31019 阅读 · 0 评论 -
Python 学习笔记 列表 排序 xxx XXX
Python 学习笔记 列表 排序 xxx XXXprint("-" * 30)cars = ['bmw', 'audi', 'toyota', 'subaru']cars.sort()print(cars)print("-" * 30)cars = ['bmw', 'audi', 'toyota', 'subaru']cars.sort(reverse=True)print(cars)print("-"...原创 2020-09-15 09:36:05 · 31108 阅读 · 0 评论 -
Python 学习笔记 列表 xxx XXX
Python 学习笔记 列表 xxx XXXbicycles = ['trek', 'cannondale', 'redline', 'specialized']print(bicycles)print(bicycles[0])print(bicycles[0].title())print(bicycles[-1])names = ['wenwen', 'juanjuan', 'yuyu']for x in names: prin...原创 2020-09-14 16:43:36 · 31164 阅读 · 0 评论 -
Python 学习笔记 变量 xxx XXX
Python 学习笔记 变量 xxx XXXname = "ada lovelace"print(name.title())print(name.upper())print(name.lower())first_name = "ada"last_name = "lovelace"full_name = first_name + " " + last_nameprint(full_name)print("Hello, " + ...原创 2020-09-14 15:13:26 · 31077 阅读 · 0 评论 -
Python 斐波那契(Fibonacci)数列
Python 斐波那契(Fibonacci)数列#!/usr/bin/env python3a = 0b = 1tmp = 0while b < 100: print(b, end = ' ') tmp = a a = b b = tmp + bprint()原创 2016-05-27 20:36:16 · 134034 阅读 · 0 评论 -
Python 乘法表
Python学习笔记#!/usr/bin/env python3print("-" * 103)for i in range(1, 10): j = 1 while j <= i: print("{} * {} = {:2d}".format(j, i, i * j), end = ' ') j += 1 print()print("-" * 103)...原创 2016-05-25 21:47:41 · 11271 阅读 · 0 评论 -
Python 温度转换
Python 温度转换fahrenheit = 0print("Fahrenheit Celsius")while fahrenheit <= 250: celsius = (fahrenheit - 32) / 1.8 print("{:5d} {:7.2f}".format(fahrenheit, celsius)) fahrenheit += 25...原创 2016-05-21 07:58:43 · 11372 阅读 · 0 评论 -
Python 求 N 个数字的平均值
Python 求 N 个数字的平均值N = 10sum = 0count = 0print("please input 10 numbers:")while count < N: number = float(input()) sum += number count += 1 average = sum /Nprint("N = {}, Sum = {}".format(N, sum))p...原创 2016-05-21 07:57:57 · 15451 阅读 · 1 评论 -
Python学习笔记
Python学习笔记 for i in range(1, 101): if i % 7 == 0: continue elif i % 10 == 7: continue elif i // 10 == 7: continue else: print(i)原创 2016-05-21 07:57:22 · 11346 阅读 · 0 评论 -
Python学习笔记
Python学习笔记nameList = ["aaa", "bbb", "ccc"]for idx in nameList: print(idx)原创 2016-05-21 07:56:37 · 11247 阅读 · 0 评论 -
Python学习笔记
Python学习笔记 #!/usr/bin/env python3n = int(input("Enter the number of students: "))data = {} # 用来存储数据的字典变量Subjects = ('Physics', 'Maths', 'History') # 所有科目for i in range(0, n): name = input('Ent...原创 2016-05-27 20:36:46 · 11127 阅读 · 0 评论 -
Python学习笔记
Python学习笔记print('hello, world')name = input("Enter the name: ")print("name: ", name)print("{} * {} = {}".format(1024, 768, 1024 * 768))print("测试中文")print('growth rate: %d %%' % 7)names = ['aa', 'bb', 'cc']for x in n...原创 2020-09-05 16:01:48 · 30988 阅读 · 0 评论 -
Python学习笔记
Python学习笔记#!/usr/bin/env python3fobj = open("sample.txt")b = fobj.readline()print(b)a = fobj.read()fobj.close()print(a)print("-" * 30)x = open("sample.txt")c = x.readline()x.clos...原创 2016-05-27 20:37:30 · 11374 阅读 · 0 评论 -
python 学习笔记
python 学习笔记#!/usr/bin/env python3import mathdef longest_side(a, b): """ Function to find the length of the longest side of a right triangle. :arg a: Side a of the triangle :arg b: Side b of...原创 2016-05-27 20:38:28 · 11325 阅读 · 0 评论 -
Linux 执行./test.py 报错 : Syntax error: “(“ unexpected
Linux 执行./test.py 报错 : Syntax error: "(" unexpectedpy文件头部添加#!/usr/bin/env python3原创 2020-08-26 10:47:19 · 31658 阅读 · 0 评论
分享