我的思路利用set取交集看交集来判断就可以了。 11.JPG (8.34 KB, 下载次数: 46) 下载附件 2018-12-26 20:30 上传
回答于 2021-09-23 22:51
谢谢!这样可以了。join的参数得是字符串,g的元素原来都是int,对吧? 如果g = ( x for x in 'ABC' ) 我就可以直接print(','.join(g))了,这样理解对吗?
回答于 2021-09-23 22:49
献丑#!/usr/bin/env python# -*- coding: utf-8 -*-# Created by lightwave on 2017/9/6# Copyright (c) 2017 lightwave. All rights reserved.from itertools import productdef func(num_count, num_sun, start=0, end=10, is_repeat=False): """ 如果a,b,c,d,e均为<=10的整数,sum=a+b+c+d+e,sum=17,...
回答于 2021-09-23 22:47
献丑#!/usr/bin/env python# -*- coding: utf-8 -*-# Created by lightwave on 2017/9/6# Copyright (c) 2017 lightwave. All rights reserved.from collecti** import defaultdicttemp_list = ["SHFE.al", "SHFE.cu", "SHFE.zn", "CZCE.SR", "CZCE.CF", "CZCE.CY", "CZCE.ZC", "DCE.m", "DCE.y",...
回答于 2021-09-23 22:26
谢谢!我用了个笨办法,改成这样算是勉强通过了,但是感觉很啰嗦,请问我怎么改那一部分比较好呢? def is_legitmate_code(code): code_letters = ["A", "B", "Z", "T", "X"] min_for_each_letter = [2, 2, 1, 0, 4] max_for_each_letter = [8, 9, 6, 7, 5] code_list = code.split() code2 = "" ...
回答于 2021-09-23 22:23
老师, 仓库和型号组合在一起进行分组 , 分组跟仓库也有关, 老师代码的结果2个价格是独立显示出来的 , 没有型号和仓库等信息了, 我想最终得到结果的这种表格形式的dataframe, 代码如何写呢, 谢谢老师, 型号 数量 加权平均价 仓库 A 7 13.08 仓库1 A 2 ...
回答于 2021-09-23 22:21
根據你的代碼做出更改如下: 全局變量放外面a = []b = []for i in range(6): if i%2 == 0: a.append(i) else: b.append(i)print(a, b) # [0, 2, 4] [1, 3, 5]复制代码 我有更為簡單的代碼,如下:a = [i for i in range(6) if i%2 == 0]b = [i for i in range(6) if i%2 == 1]print(a, b) # [0, 2, 4]...
回答于 2021-09-23 22:17
樓主,因為pandas並不是我的強項,所以關於第一點我沒有辦法幫你優化或簡化,不好意思。第二點,關於無法顯示前2行,我用你的代碼沒有問題,可以顯示,有可能個人電腦作業系統不一樣關係吧,你可以試試多加兩行代碼試試:import pandas as pdimport numpy as npdf = pd.DataFrame({'型号':['A','A','A','A','B',], ...
回答于 2021-09-23 22:14
变量值: >>> name = 'Eric' 输出时: >>> print('Hello %s, would you like to learn some Python today?' %name) Hello Eric, would you like to learn some Python today? 或者 >>> print('Hello {}, would you like to learn some Python today?'.format(name)) Hello Eric, would you lik...
回答于 2021-09-23 22:05