1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

教えてもらったコードの理解を深める 

Posted at

昨日教えてもらったコードのわからないところを調べて自分なりのコメントで説明を書いてみる。

pwj.py

# パスワードジェネレーター ver1.0 (数字 アルファベット小文字大文字混合)
import random

# 0-9の数字とアルファベット大文字小文字の塊?を読み込む
from string import digits, ascii_letters

# charactersの中身は(0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)
characters = digits + ascii_letters

size = int(input("何ケタのパスワードにしますか? "))

# ''で無を表している?ので charactersからrandom.choiceで取り出している

password = ''.join(random.choice(characters) for _ in range(size))

print(password)

for _ in range(size) の処理は 作るときに求められた桁数を表示するための処理?でいいのかな・・・

今の段階で自分がよく見るforの書き方は

for i in range():
    print(i)

みたいなやつだったので _ の部分とかは
どういう処理をしてるんだろう。。

1
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?