你再掐我试试 发表于 2020-4-18 22:13:34

for each_movie in ws['A1':'B251']:
        if each_movie.value == '阿甘正传':
                each_movie.value = '9.8'
        if each_movie.value == '这个杀手不太冷':
                each_movie.value = '9.6'
        if each_movie.value == '肖申克的救赎':
                each_movie.value = '9.7'

zhlt 发表于 2020-4-22 20:08:20

看看

15295030992 发表于 2020-4-23 14:45:06

2

shatanzongcai 发表于 2020-4-23 18:53:05

ws= wb['ns 1']
c = ws['C4']
c.value = '9.8'

Spin 发表于 2020-4-23 19:48:25

for each_row in sheetcopy.rows:
    if each_row == "《阿甘正传》":
      each_row = 9.8
    if each_row == "《这个杀手不太冷》":
      each_row = 9.6
    if each_row == "《阿甘正传》":
      each_row = 9.7
wb.save(r"D:\Desktop\python练习\python-excel\P1\豆瓣Top250电影.xlsx")

时文昌 发表于 2020-4-24 18:36:52

厉害了小甲鱼

nonamenochat 发表于 2020-4-25 21:48:32

openpyxl.cell.cell.column_index_from_string('JB')
这个代码运行时显示:AttributeError: module 'openpyxl.cell.cell' has no attribute 'column_index_from_string'

sjtuszy 发表于 2020-4-26 13:39:43

ws['B2'] = 9.7
ws['B4'] = 9.6
ws['B5'] = 9.8

capslockabc 发表于 2020-4-27 14:06:34

朕想知道

西电梅西 发表于 2020-4-27 17:04:46

朕来了

Pyshell 发表于 2020-4-27 17:57:33

1

jin.xia@zju 发表于 2020-4-28 09:41:15

回复看答案

tudeyouxiu 发表于 2020-4-29 18:57:38

wb = openpyxl.load_workbook('F:\python\豆瓣top250电影.xlsx')
ws = wb['Sheet Copy2']
c1 = ws['B2']
c1.value = '9.8'

饮东篱 发表于 2020-4-29 19:10:53

可以直接赋值,更高级的实在不会

Dammit 发表于 2020-5-1 21:47:12

.

堕落之画 发表于 2020-5-2 16:38:20

{:5_108:}

rsj0315 发表于 2020-5-3 01:00:33

看看

RandallSteven 发表于 2020-5-3 17:41:19

change = {'阿甘正传':9.8}
for each in ws.rows:
    if each.value in change.keys():
      each.value = change.value]

lemon_wb 发表于 2020-5-3 23:57:54

想看习题答案{:5_108:}

rr91 发表于 2020-5-5 16:23:00

下不了,币少了
页: 5 6 7 8 9 10 11 12 13 14 [15] 16 17 18 19 20 21 22 23 24
查看完整版本: 使用Python读写Excel文件(2)