• 1. MAC


    1. 本人的电脑是14年的MAC  ,所以每次打开PyCharm 都很慢,让我怀疑是否 PyCharm 安装错误。

    2. 创建新的python 项目:

    • python菜单 -> File  -> New Project...

    3. Location:

    • 项目存储的位置:如 /Users/用户名/Desktop/untitled1

    4. Interpreter:

    • 项目使用的 Python 的版本号:如Python3 , Python2.7 (Mac默认是2.7)

    5. 定义函数:

    • python 的函数
    • def foo():
          #  这里不能 不缩进,因为没有花括号进行 保护。只有 缩进来规定语法
          print("hello world")
      
      # 函数调用
      foo()
    •  Swift 的函数
    func foo() {
         print("你好")   
    }

    6. 变量的定义与赋值

    • Python : 解释性语言且具有强类型转换能力,所以不需要申明变量名与变量类型,而是直接给变量赋值即可
    • # 动态语言
      s = 1
      print(type(s))
      s = '1'
      print(type(s))
      s = None
      print(type(s))
      s = True
      print(type(s))
      
      # type : 查看变量类型
    • Swift : 强类型语言
    • var i = 0
      let i = 4
      
      // var 变量
      // let  常量 
      // i = 0  Int 类型
      // i = "string" String 类型 
      ...

    7. if 语句

    • Python
    • def foo():
          a = 10
          if a > 10:
              print("hello 10+")
          elif 5 < a <= 10 :
              print("hello 5+")
          else :
              print("low")
      
      
      foo()
      •   false : False or {} or [] or () or None or "" or 0
    • Swift
    • let i = 10
      if i > 10 {
          print("hello 10+")
      }else if i > 5 && i <= 10 {
          print("hello 5+")
      }else {
          print("low")
      }

    8. for in 循环

    • Python : 只能循环 迭代器:
      •   元祖,字典,列表
      • # range -> 自动生成 数组
        # range(100) -> 自动生成 0 - 99 个数字
        
        # 获取数字索引
        for i in range(100):
            print(i)

    9. 类的关键字:

    • Python:
    class Foo(object):
    • Swift
    • class Foo: NSObject {
      
      }
  • 相关阅读:
    LyX – The Document Processor
    An HTML5 presentation builder — Read more
    R语言定义
    A Hybrid User and ItemBased Collaborative Filtering with Smoothing on Sparse Data
    RapidMiner
    http://www.rseek.org一个查找R资料的站点
    An HTML5 presentation builder — Read more
    R代码脚本的运行
    data ming with R a book
    A Hybrid User and ItemBased Collaborative Filtering with Smoothing on Sparse Data
  • 原文地址:https://www.cnblogs.com/iOS363536404/p/7105202.html
Copyright © 2020-2023  润新知