本文目錄一覽:
- 1、求解 python 練習題
- 2、推薦幾個適合新手練手的Python項目
- 3、Day014 Python 數據類型之元組
- 4、Python實現的排列組合計算操作示例
- 5、python入門教程
- 6、Python視頻教程,百度雲
求解 python 練習題
import string
def makeWordList(input_file, output_file):
table = string.maketrans(“”, “”)
try:
word_list = dict()
for line in open(input_file, ‘r’):
line = line.translate(table, string.punctuation).rstrip(‘\r\n’).split(‘ ‘)
for word in line:
if not word in word_list:
word_list[word] = 1
else:
word_list[word] += 1
f = open(output_file, ‘w’)
for k,v in word_list.items():
line = ‘%s %s\r\n’ % (k,v)
f.write(line)
except:
print input_file,’not exist’
makeWordList(‘input.txt’, ‘output.txt’)
推薦幾個適合新手練手的Python項目
《Python實戰:四周實現爬蟲系統》百度網盤免費下載
鏈接:
提取碼: xbdu
Python實戰:四周實現爬蟲系統
Day014 Python 數據類型之元組
今兒我們再續前緣,接着List開始說。
元組和List特別像,區別是元組中的數據不可以修改。
為表區別,元組的標識符用的是小括號(),而List是用的中括號[]
舉個栗子
tup2 = (1, 2, 3, 4, 5 )
不可修改屬性,這也是和List最大區別
元組中的元素值也不能修改,但可以用del語句,刪除整個元組
以上
我正在從0開始學習Python,想找夥伴一起學習討論,感興趣的夥伴可以一起~
Python實現的排列組合計算操作示例
Python實現的排列組合計算操作示例
本文實例講述了Python實現的排列組合計算操作。分享給大家供大家參考,具體如下:
1. 調用 scipy 計算排列組合的具體數值
from scipy.special import comb, perm
perm(3, 2)
6.0
comb(3, 2)
3.0
2. 調用 itertools 獲取排列組合的全部情況數
from itertools import combinations, permutations
permutations([1, 2, 3], 2)
itertools.permutations at 0x7febfd880fc0
# 可迭代對象
list(permutations([1, 2, 3], 2))
[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
list(combinations([1, 2, 3], 2))
[(1, 2), (1, 3), (2, 3)]
python入門教程
《【3】學習視頻》百度網盤資源免費下載
鏈接:
提取碼:m6tm
【3】學習視頻|python視頻教程|Python入門基礎視頻教程|lets python 視頻教程|Lets-python-017-文件和輸入輸出01.avi|Lets-python-016-條件和循環02-練習題和生成器.avi|Lets-python-015-條件和循環01.avi|Lets-python-014-映射和集合02.avi|Lets-python-013-映射和集合01.avi|Lets-python-012-序列04-02.avi|Lets-python-012-序列04-01.avi|Lets-python-011-del和getattr.avi|Lets-python-010-序列03.avi|lets-python-009-序列02.avi|Lets-python-008-序列01.avi
Python視頻教程,百度雲
[python視頻教程] lets python視頻教程免費下載
鏈接:
提取碼:dxpn
[python視頻教程] lets python 視頻教程|Lets-python-017-文件和輸入輸出01.avi|Lets-python-016-條件和循環02-練習題和生成器.avi|Lets-python-015-條件和循環01.avi|Lets-python-014-映射和集合02.avi|Lets-python-013-映射和集合01.avi|Lets-python-012-序列04-02.
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/286094.html