About

Welcome to MagicianYang’s blog! I’m a newbie in coding. So I want to write down the notes of coding and manage to organize my own way for learning it. I love reading novels, watching TV series/movies/cartoons, listening to musics. So maybe I will also record my thoughts about my hobbies.

The blog’s name is from a main character in Legend of Galactic Heroes (a series of ten science-fiction novels written by Tanaka Yoshiki), whose name is Yang Wen-li. And he is my favourite character. He has the nicknames “Miracle Yang” and “Yang the Magician” in Legend of Galactic Heroes, so I pick one of them as my blog’s name. The icon is the Tardis from Doctor Who(a British science-fiction television programme produced by the BBC).

Thanks to { Personal } Jekyll Theme. It is a really beautiful theme for a blog. And actually, this blog is based on Jekyll theme and github pages. Try to set up your own blog and enjoy it! (^ω^)

Latest Blog Post

31 May 2017 . tech . ip地址获取或转换 Comments

django从request里面获取ip def get_ip(request): try: real_ip = request.META[‘HTTP_X_FORWARDED_FOR’] reg_ip = real_ip.split(“,”)[0] except KeyError: try: reg_ip = request.META[‘REMOTE_ADDR’] except KeyError: return 0 str -> int def ip_str2int(ip_address: str) -> int: ip_list = ip_address.split(‘.’) ans = 0 for item in ip_list: try: ans = (ans << 8) + int(item) except ValueError: continue return ans int -> str def ip_int2str(num: int) -> str: “”” 更为清晰的转换 “”” ip4 = num & 255 num = num >> 8 ip3 = num & 255 num = num >> 8 ip2 = num…

View more posts

Timeline

  • Decemeber 2014 - Today

    Start coding in python

Contact

Drop me an email if you have interesting idea about coding or sharing brilliant thoughts with me.