noteBook2.7-C#基础第七天

构造函数:帮助初始化对象(给对象的每个属性依次赋值)

是一个特殊的方法

1.构造函数没有返回值,也不用写void;

2.构造函数的名称必须与类名一样;

*创建函数的时候会执行构造函数;

*构造函数可以重载;

*类中默认有一个无参的构造函数,当写一个新的构造函数后,不管有参数还是无参数,默认的无参构造函数就被替代了。

 public class ProgramTest
    {
        int j;
        public ProgramTest()
        {
            j = 4;
            Console.WriteLine("I am ProgramTest,{0}", j);
        }
        static void Main(string[] args)
        {
            ProgramTest pt = new ProgramTest();
            Console.Read();
        }

结果为:I am ProgramTest,4

new关键字:

Person      sPerson=new   Person();

做了三件事:

1.在内存中开辟了一块空间;

2.在开辟的空间中创建对象;

3.调用对象的构造函数进行初始化对象。

this关键字:

1.代表当前类的对象;

2.在类中显示调用本类的构造函数,格式为(:this)。

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace NoteBook { /// <summary> /// About 的摘要说明。 /// </summary> public class About : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public About() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(About)); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.ForeColor = System.Drawing.Color.Red; this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image"))); this.label1.Location = new System.Drawing.Point(0, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(496, 128); this.label1.TabIndex = 0; this.label1.Text = "label1"; // // label2 // this.label2.Font = new System.Drawing.Font("华文新魏", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.label2.Location = new System.Drawing.Point(16, 147); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(192, 32); this.label2.TabIndex = 1; this.label2.Text = "记事本编辑器"; // // label3 // this.label3.Font = new System.Drawing.Font("华文行楷", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.label3.ForeColor = System.Drawing.Color.RoyalBlue; this.label3.Location = new System.Drawing.Point(16, 224); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(232, 24); this.label3.TabIndex = 2; this.label3.Text = " 版权所有,翻版必究!"; // // label4 // this.label4.Font = new System.Drawing.Font("华文新魏", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.label4.Location = new System.Drawing.Point(240, 151); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(248, 32); this.label4.TabIndex = 3; this.label4.Text = "计算机3063班 C#课程设计 "; // // label5 // this.label5.Image = ((System.Drawing.Image)(resources.GetObject("label5.Image"))); this.label5.Location = new System.Drawing.Point(256, 197); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(240, 64); this.label5.TabIndex = 4; // // About // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(496, 262); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.ForeColor = System.Drawing.Color.Red; this.Name = "About"; this.Text = "关于我的记事本"; this.ResumeLayout(false); } #endregion } }
`nohup jupyter notebook --allow-root&` 是一个用于在后台启动 Jupyter Notebook 并允许以 root 用户身份运行的命令。 ### 命令解析 - `nohup`:该命令用于忽略挂起信号(SIGHUP),当用户退出登录或终端关闭时,进程不会被终止,从而可以在后台持续运行。 - `jupyter notebook`:启动 Jupyter Notebook 服务。 - `--allow-root`:允许以 root 用户身份运行 Jupyter Notebook。在某些系统中,默认情况下不允许 root 用户直接启动 Jupyter Notebook,使用该参数可以绕过此限制。 - `&`:将命令放入后台执行,终端可以继续执行其他命令。 ### 作用 此命令可以让 Jupyter Notebook 在后台持续运行,即使关闭终端或退出登录也不会停止。同时,允许 root 用户启动服务,适用于需要 root 权限的场景。 ### 使用方法 在终端中直接输入 `nohup jupyter notebook --allow-root&` 并回车,即可在后台启动 Jupyter Notebook 服务。如果需要将输出信息保存到文件中,可以使用 `nohup jupyter notebook --allow-root >> out.log 2>&1 &` 命令,将标准输出错误输出都重定向到 `out.log` 文件中 [^1]。 ### 常见题及解决办法 - **权限题**:如果系统仍然不允许 root 用户启动 Jupyter Notebook,可能需要检查系统的安全策略或配置文件。可以尝试编辑 `jupyter_notebook_config.py` 文件,添加或修改相关配置项,如 `c.NotebookApp.allow_root = True` [^3]。 - **端口冲突**:如果指定的端口已被其他程序占用,Jupyter Notebook 可能无法启动。可以通过修改配置文件中的 `c.NotebookApp.port` 参数来指定其他可用端口 [^5]。 - **输出文件权限题**:如果使用 `>> out.log` 将输出信息保存到文件中,可能会遇到文件权限不足的题。可以使用 `sudo` 命令以 root 权限执行命令,或者修改文件的权限。 ### 代码示例 ```bash nohup jupyter notebook --allow-root >> out.log 2>&1 & ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值