Harigami
ログイン
anonymous タイトルなし
Python
import urllib.request

response = urllib.request.urlopen('https://docs.python.org/')
print(response)
  • 0
  • 0
anonymous タイトルなし
Python
import urllib

response = urllib.request.urlopen('https://docs.python.org/')
print(response)
  • 0
  • 0
anonymous タイトルなし
Python
import http
http.client.HTTPConnection('www.python.org')
  • 0
  • 0
出口尚哉 プロ演2第1週課題4
Python
keitou_list={"12号系統":0,"15号系統":0,"50号系統":0,"51号系統":0,"55号系統":0,"59号系統":0,"M1号系統":0,"快速202号系統":0,"快速205号系統":0}
with open('data/kyotocitybus_stop.dat',"r", encoding = 'utf-8') as fi:
    lines = fi.readlines()
    for line in lines:
        line = line.rstrip()
        items = line.split(' ') #1行を半角スペースで区切ってitemsリストに代入
        for i in items[4::]:
            if i in keitou_list:
                keitou_list[i]+=1
for i in keitou_list:
    print("{}の停留所の合計は{}個です。".format(i,keitou_list[i]))
  • 0
  • 0
出口尚哉 プロ演2第1週課題3
Python
fi = open('data/kyotocitybus_stop.dat',"r", encoding = 'utf-8')
lines = fi.readlines()
for line in lines:
    line = line.rstrip()
    items = line.split(' ') #1行を半角スペースで区切ってitemsリストに代入
    if items[1]=="立命館大学前":
        for i in items[4::]:
            print(i+",",end="")
fi.close()
  • 0
  • 0
出口尚哉 プロ演2第1週課題2
Python
with open('data/kyotocitybus_stop.dat',"r", encoding = 'utf-8') as fi:
    with open('data/kyotocitybus_stop_comma.dat',"w", encoding = 'utf-8') as le:
        lines = fi.readlines()
        for line in lines:
            line = line.rstrip()
            items = line.split(' ') #1行を半角スペースで区切ってitemsリストに代入
            le.write(','.join(items)+"\n") #カンマを区切り文字としてitemsリストの要素を連結
  • 0
  • 0
出口尚哉 プロ演2第一週課題1
Python
fi = open('data/kyotocitybus_stop.dat',"r", encoding = 'utf-8')
lines = fi.readlines()
for line in lines:
    line = line.rstrip()
    items = line.split(' ') #1行を半角スペースで区切ってitemsリストに代入
    print(','.join(items)) #カンマを区切り文字としてitemsリストの要素を連結
fi.close()
  • 0
  • 0
anonymous タイトルなし
Python
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.group_count = n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.group_count -= 1

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

def int_(num_str):
    return int(num_str) - 1


N, K, L = map(int, input().split())
uf1 = UnionFind(N)
for _ in range(K):
    p, q = map(int_, input().split())
    uf1.union(p, q)
uf2 = UnionFind(N)
for _ in range(L):
    r, s = map(int_, input().split())
    uf2.union(r, s)
from collections import Counter
pair = [(uf1.find(i), uf2.find(i)) for i in range(N)]
ans = Counter(pair)
print(*[ans[p] for p in pair])
  • 0
  • 0
anonymous タイトルなし
Python
hi there 
I have just checked harigami.jp for the ranking keywords and seen that your SEO metrics could use a boost. 
 
We will improve your SEO metrics and ranks organically and safely, using only whitehat methods, while providing monthly reports and outstanding support. 
 
Please check our pricelist here, we offer SEO at cheap rates. 
https://www.hilkom-digital.de/cheap-seo-packages/ 
 
Start increasing your sales and leads with us, today! 
 
regards 
Hilkom Digital Team 
support@hilkom-digital.de
  • 0
  • 0
anonymous タイトルなし
Python
N = int(input())

R=[]
B=[]

for i in range(N):
  x, c = input().split()
  if c == 'R':
    R.append(int(x))
  else:
    B.append(int(x))

R.sort()
B.sort()

if R != []:
    for r in(R):
        print(r)

if B != []:
    for b in(B):
        print(b)
  • 0
  • 0
あなたもコードを投稿しませんか?
投稿する