我需要创建一个public class EfItem
{
public string Id { get; set; }
public string SortId { get; set; }
public string ParentId { get; set; }
public string Head { get; set; }
public short ElementCode { get; set; }
public int LegacyNumber { get; set; }
public int Flags { get; set; }
public string Lemma { get; set; }
public short Homograph { get; set; }
public string Content { get; set; }
public DateTime TimeCreated { get; set; }
public string CreatorId { get; set; }
public IList<EfNote> Notes { get; set; }
}
public class EfNote
{
public string Id { get; set; }
public string ItemId { get; set; }
public Item Item { get; set; }
public string BookmarkId { get; set; }
public string UserId { get; set; }
public string Text { get; set; }
public byte Level { get; set; }
public DateTime TimeCreated { get; set; }
}
程序,它会说出随机选择的数字。比如,protected override void OnModelCreating(DbModelBuilder mb)
{
mb.Conventions.Remove<PluralizingTableNameConvention>();
// item
mb.Entity<EfItem>().ToTable("Item");
mb.Entity<EfItem>().Property(i => i.Id).IsFixedLength().HasMaxLength(32)
.IsRequired().IsUnicode(false);
mb.Entity<EfItem>().Property(i => i.SortId).HasMaxLength(500)
.IsRequired().IsUnicode(false);
mb.Entity<EfItem>().Property(i => i.ParentId).IsFixedLength().HasMaxLength(32)
.IsUnicode(false);
mb.Entity<EfItem>().Property(i => i.Head).HasMaxLength(50).IsUnicode(true);
mb.Entity<EfItem>().Property(i => i.ElementCode).IsRequired();
mb.Entity<EfItem>().Property(i => i.LegacyNumber).IsRequired();
mb.Entity<EfItem>().Property(i => i.Flags).IsRequired();
mb.Entity<EfItem>().Property(i => i.Lemma).HasMaxLength(200).IsRequired();
mb.Entity<EfItem>().Property(i => i.Homograph).IsRequired();
mb.Entity<EfItem>().Property(i => i.Content).IsRequired().IsUnicode(true)
.HasColumnType("xml");
mb.Entity<EfItem>().Property(i => i.TimeCreated)
.IsRequired()
.HasColumnType("datetime2");
mb.Entity<EfItem>().Property(i => i.CreatorId).HasMaxLength(100).IsRequired();
// notes
mb.Entity<EfNote>().ToTable("Note");
mb.Entity<EfNote>().Property(n => n.Id).IsFixedLength().HasMaxLength(32)
.IsRequired().IsUnicode(false);
mb.Entity<EfNote>().Property(n => n.ItemId).IsFixedLength().HasMaxLength(32)
.IsRequired().IsUnicode(false);
mb.Entity<EfNote>().Property(n => n.BookmarkId)
.HasMaxLength(50).IsUnicode(false).IsRequired();
mb.Entity<EfNote>().Property(n => n.UserId).HasMaxLength(100).IsRequired();
mb.Entity<EfNote>().Property(n => n.Text).HasMaxLength(2000).IsRequired();
mb.Entity<EfNote>().Property(n => n.Level).IsRequired();
mb.Entity<EfNote>().Property(n => n.TimeCreated).IsRequired()
.HasColumnType("datetime2");
base.OnModelCreating(mb);
}
给我11号,而CREATE TABLE [dbo].[Item](
[Id] [char](32) NOT NULL,
[SortId] [varchar](500) NOT NULL,
[ParentId] [char](32) NULL,
[Head] [nvarchar](50) NULL,
[ElementCode] [smallint] NOT NULL,
[LegacyNumber] [int] NOT NULL,
[Flags] [int] NOT NULL,
[Lemma] [nvarchar](200) NOT NULL,
[Homograph] [smallint] NOT NULL,
[Content] [xml] NOT NULL,
[CreatorId] [nvarchar](100) NOT NULL,
[TimeCreated] [datetime2](7) NOT NULL,
CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
CREATE TABLE [dbo].[Note](
[Id] [char](32) NOT NULL,
[ItemId] [char](32) NOT NULL,
[BookmarkId] [varchar](50) NOT NULL,
[UserId] [nvarchar](100) NOT NULL,
[Text] [nvarchar](2000) NOT NULL,
[Level] [tinyint] NOT NULL,
[TimeCreated] [datetime2](7) NOT NULL,
CONSTRAINT [PK_Note] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
则表示“11”。这很简单,我几乎创造了所有东西,但我唯一需要的是 - 让Python
使用Python
说出来!
拜托,你能给我一些例子吗?
答案 0 :(得分:1)
有一个名为pyttsx
的python模块可以说明事情。您可以使用pip install pyttsx
安装它,然后将其用作
import pyttsx as tts
engine = tts.init()
engine.say('Eleven')
engine.runAndWait()